/**
 * @program: LeetCode
 * @description: LeetCode : 968. 监控二叉树
 * @author: WXY
 * @create: 2023-01-28 12:57
 * @Version 1.0
 *
 *   有点复杂，没有做出来。。。。。日后在做。放弃。。。
 **/
public class Num968_minCameraCover {
    public static class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }

  public static class Info{
        int ans;
        boolean isFatherCover;

      public Info(int ans, boolean isFatherCover) {
          this.ans = ans;
          this.isFatherCover = isFatherCover;
      }
  }

    public static int minCameraCover(TreeNode root) {
        if (root.left == null && root.right == null)return 1;
        Info ans = process(root);
        return ans.ans;
    }

    private static Info process(TreeNode root) {
        if (root.right == null && root.left == null) {
            return new Info(0,false );
        }
        Info leftInfo = null;
        Info rightInfo = null;
        if (root.left != null) {
            leftInfo = process(root.left);
        }
        if (root.right != null) {
            rightInfo = process(root.right);
        }
        boolean isFatherCover = false;
        int yes = 0;
        int no = 0;
        if (leftInfo != null || rightInfo != null) {
            if (leftInfo != null && leftInfo.isFatherCover) {

            }
        }
        int ans = 0;
        if (isFatherCover) {
            ans = yes;
        } else {
            ans = no;
        }
        return new Info(ans, isFatherCover);
    }

    public static void main(String[] args) {
        TreeNode head = new TreeNode(0);
        head.left = new TreeNode(0);
        head.left.right = new TreeNode(0);
        head.left.right.left = new TreeNode(0);
        head.left.right.left.right = new TreeNode(0);
        head.left.right.left.right.left = new TreeNode(0);

        int ans1 = minCameraCover(head);
        System.out.println(ans1);

        TreeNode head1 = new TreeNode(0);
        head1.left = new TreeNode(0);
        head1.left.left = new TreeNode(0);
        head1.left.left.left = new TreeNode(0);
        head1.left.left.left.right = new TreeNode(0);
        System.out.println(minCameraCover(head1));

    }

}
